//package com.travel.travelServer.service1.impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.github.pagehelper.PageHelper;
//import com.github.pagehelper.PageInfo;
//import com.travel.travelServer.entity1.Landscapes;
//import com.travel.travelServer.entity1.ThailLandscapes;
//import com.travel.travelServer.entity1.Thali;
//import com.travel.travelServer.entity1.vo.ThaliVo;
//import com.travel.travelServer.mapper1.LandscapesMapper;
//import com.travel.travelServer.mapper1.ThailLandscapesMapper;
//import com.travel.travelServer.mapper1.ThailMapper;
//import com.travel.travelServer.service1.ThailServie;
//import com.travel.travelServer.utils.BaseService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.Date;
//import java.util.List;
//import java.util.stream.Collectors;
//
//@Service
//public class ThailServieImpl extends BaseService<ThailMapper, Thali> implements ThailServie {
//
//    @Autowired
//    ThailMapper thailMapper;
//
//    @Autowired
//    ThailLandscapesMapper thailLandscapesMapper;
//
//    @Autowired
//    LandscapesMapper landscapesMapper;
//
//    /**
//     * 新增Thail
//     *
//     * @param thailVo
//     * @return 结果
//     */
//    @Transactional(rollbackFor = Exception.class)
//    @Override
//    public int insertThail(ThaliVo thailVo) {
//        Date date = new Date();
//        thailVo.setCreateTime(date);
//        thailVo.setUpdateTime(date);
//        thailVo.setCreateBy("admin");
//        thailVo.setUpdateBy("admin");
//        thailMapper.insert(thailVo);
//        if (thailVo.getLandscapes().size() > 0){
//            for (Landscapes landscape : thailVo.getLandscapes()) {
//                ThailLandscapes thailLandscapes = new ThailLandscapes();
//                thailLandscapes.setThaliId(thailVo.getId());
//                thailLandscapes.setLandscapesId(landscape.getId());
//                thailLandscapesMapper.insert(thailLandscapes);
//            }
//        }
//        return 1;
//    }
//
//    /**
//     * 单个删除Thail信息
//     *
//     * @param id-主键
//     * @return 结果
//     */
//    @Transactional(rollbackFor = Exception.class)
//    @Override
//    public int deleteById(Long id) {
//        thailMapper.deleteById(id);
//        LambdaQueryWrapper<ThailLandscapes> wrapper = new LambdaQueryWrapper<>();
//        wrapper.eq(ThailLandscapes::getThaliId, id);
//        thailLandscapesMapper.delete(wrapper);
//        return 1;
//    }
//
//    /**
//     * 批量删除Thail信息
//     *
//     * @param ids-主键[]
//     * @return 结果
//     */
//    @Transactional(rollbackFor = Exception.class)
//    @Override
//    public int deleteByIds(Long[] ids) {
//        return thailMapper.deleteBatchIds(Arrays.asList(ids));
//    }
//
//    /**
//     * 修改Thail
//     *
//     * @param thailVo
//     * @return 结果
//     */
//    @Transactional(rollbackFor = Exception.class)
//    @Override
//    public int updateThail(ThaliVo thailVo) {
//        thailMapper.updateById(thailVo);
////        LambdaQueryWrapper<ThailMenu> wrapper = new LambdaQueryWrapper<>();
////        wrapper.eq(ThailMenu::getThailId, thailVo.getId());
////        thailMenuMapper.delete(wrapper);
////        List<Long> menuIds = thailVo.getMenuIds();
////        if (menuIds.size() > 0){
////            for (Long menuId : menuIds) {
////                ThailMenu thailMenu = new ThailMenu();
////                thailMenu.setThailId(thailVo.getId());
////                thailMenu.setMenuId(menuId);
////                thailMenuMapper.insert(thailMenu);
////            }
////        }
//        return 1;
//    }
//
//    /**
//     * 查询Thail
//     *
//     * @param id-主键
//     * @return thail
//     */
//    @Override
//    public Thali selectById(Long id) {
//        return thailMapper.selectById(id);
//    }
//
//    /**
//     * 查询Thail列表
//     *
//     * @param thailVo
//     * @return Thail集合
//     */
//    @Override
//    public List<Thali> selectThailList(ThaliVo thailVo) {
//        LambdaQueryWrapper<Thali> queryWrapper = new LambdaQueryWrapper<>();
//        //queryWrapper.eq(Thail::getId, thailVo.getId).select(Thail::getId);
//        return thailMapper.selectList(queryWrapper);
//    }
//
//    @Override
//    public PageInfo<Thali> getInfoPage(ThaliVo thailVo) {
//        // 使用 PageHelper 分页
//        PageHelper.startPage(thailVo.getPageNum(), thailVo.getPageSize());
//        LambdaQueryWrapper<Thali> wrapper = new LambdaQueryWrapper<>();
//        wrapper.like(Thali::getName, thailVo.getName());
//        List<Thali> thalis = thailMapper.selectList(wrapper);
//        if (thalis.size() > 0){
//            for (Thali thali : thalis) {
//                LambdaQueryWrapper<ThailLandscapes> queryWrapper = new LambdaQueryWrapper<>();
//                queryWrapper.eq(ThailLandscapes::getThaliId, thali.getId());
//                List<ThailLandscapes> thailLandscapes = thailLandscapesMapper.selectList(queryWrapper);
//                List<Long> landscapeIds = thailLandscapes.stream().map(thailLandscapes1 -> thailLandscapes1.getLandscapesId()).collect(Collectors.toList());
//                List<Landscapes> list = new ArrayList<>();
//                for (Long landscapeId : landscapeIds) {
//                    Landscapes landscapes = landscapesMapper.selectById(landscapeId);
//                    list.add(landscapes);
//                }
//                thali.setLandscapes(list);
//            }
//        }
//        return new PageInfo<>(thalis);
//    }
//}
